<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>测试页面</title>
<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath}/static/jquery-easyui-1.3.3/themes/default/easyui.css">
<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath}/static/jquery-easyui-1.3.3/themes/icon.css">
<script type="text/javascript"
	src="${pageContext.request.contextPath}/static/jquery-easyui-1.3.3/jquery.min.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/static/jquery-easyui-1.3.3/jquery.easyui.min.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/static/jquery-easyui-1.3.3/locale/easyui-lang-zh_CN.js"></script>
<script type="text/javascript">
	var url;
	function openTab(text, url, iconCls) {
		if ($("#tabs").tabs("exists", text)) {
			$("#tabs").tabs("select", text);
		} else {
			var content = "<iframe frameborder=0 scrolling='auto' style='width:100%;height:100%' src='${pageContext.request.contextPath}/page/" + url + "'></iframe>";
			$("#tabs").tabs("add", {
				title : text,
				iconCls : iconCls,
				closable : true,
				content : content
			});
		}
	}
	
	function openPasswordModifyDialog(){
		$("#dlg").dialog("open").dialog("setTitle","修改密码");
		url="${pageContext.request.contextPath}/user/modifyPassword.do?id=${currentMemberShip.user.id}&password=${currentMemberShip.user.password}";
	}
	
	function modifyPassword(){
		$("#fm").form("submit",{
			url:url,
			onSubmit:function(){
				var oldPassword=$("#oldPassword").val();
				var newPassword=$("#newPassword").val();
				var newPassword2=$("#newPassword2").val();
				if(!$(this).form("validate")){
					return false;
				}
				/*
				if(oldPassword!='${currentMemberShip.user.password }'){
					$.messager.alert("系统提示","用户原密码输入错误！");
					return false;
				}
				*/
				
				if(newPassword!=newPassword2){
					$.messager.alert("系统提示","确认密码输入错误！");
					return false;
				}
				return true;
			},
			success:function(result){
				var result=eval('('+result+')');
				if(result.success){
					$.messager.alert("系统提示","密码修改成功，下一次登录生效！");
					resetValue();
					$("#dlg").dialog("close");
				}else{
					if(result.msg!=null&&result.msg=="用户原密码输入错误！"){
						$.messager.alert("系统提示",result.msg);
					}else{
						$.messager.alert("系统提示","密码修改失败！");
					}
					return;
				}
			}
		 });
	}
	
	function closePasswordModifyDialog(){
		resetValue();
		$("#dlg").dialog("close");
	}
	
	function resetValue(){
		$("#oldPassword").val("");
		$("#newPassword").val("");
		$("#newPassword2").val("");
	}
	
	function logout(){
		$.messager.confirm("系统提示","您确定要退出系统吗？",function(r){
			if(r){
				window.top.location.href='${pageContext.request.contextPath}/user/logout.do';
			} 
		 });
	}
	
</script>
<div class="easyui-tabs" fit="true" border="false" id="tabs">
	<div title="系统管理" data-options="iconCls:'icon-jiancetai'" style="padding: 10px">
		<%-- <c:if test="${currentMemberShip.group.name=='管理员' }">
			<a href="javascript:openScanGate()" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-power'" style="width: 150px;">实时扫描开关</a>
			</c:if> --%>
		<a href="javascript:openTab('用户管理','systemConf/userManage.jsp','icon-setup')" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-setup'" style="width: 150px">用户管理</a>
		<a href="javascript:openTab('用户权限管理','systemConf/authManage.jsp','icon-testing')" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-testing'" style="width: 150px">用户权限管理</a>
		
		<a href="javascript:openPasswordModifyDialog()" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-modifyPassword'" style="width: 150px;">修改密码</a>
		<a href="javascript:logout()" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-exit'" style="width: 150px;">安全退出</a>
	</div>
</div>

<div id="dlg" class="easyui-dialog"
	style="width: 400px; height: 250px; padding: 10px 20px" closed="true"
	buttons="#dlg-buttons">

	<form id="fm" method="post">
		<table cellspacing="8px">
			<tr>
				<td>用户名：</td>
				<td><input type="text" id="userId" name="userId"
					readonly="readonly" value="${currentMemberShip.user.id }"
					style="width: 200px" /></td>
			</tr>
			<tr>
				<td>原密码：</td>
				<td><input type="password" id="oldPassword" name="oldPassword"
					class="easyui-validatebox" required="true" style="width: 200px" /></td>
			</tr>
			<tr>
				<td>新密码：</td>
				<td><input type="password" id="newPassword" name="newPassword"
					class="easyui-validatebox" required="true" style="width: 200px" /></td>
			</tr>
			<tr>
				<td>确认新密码：</td>
				<td><input type="password" id="newPassword2"
					name="newPassword2" class="easyui-validatebox" required="true"
					style="width: 200px" /></td>
			</tr>
		</table>
	</form>
</div>

<div id="dlg-buttons">
	<a href="javascript:modifyPassword()" class="easyui-linkbutton"
		iconCls="icon-ok">保存</a> <a
		href="javascript:closePasswordModifyDialog()"
		class="easyui-linkbutton" iconCls="icon-cancel">关闭</a>
</div>
</body>
</html>